package io;

import java.util.*;

public class ImageManager {
    Map<String, String> map = new HashMap<>();
    public void downloadImage(String url){
        FileUtils imageDownloader = new FileUtils();
        String fileName = url.substring(url.lastIndexOf("/") + 1);
        String savePath = "images/" + fileName;
        imageDownloader.saveImage(url,savePath);
        map.put(fileName, savePath);
    }
    public void ListImages(){
        for (String image_name : map.keySet()) {
            System.out.println("Image_name: " + image_name + "、nPath:" + map.get(image_name) + "\n");
        }
    }
    public void searchImage(String name){
        if(map.get(name) != null){
            System.out.println("图片地址为：" + map.get(name));
        }
        else{
            System.out.println("图片未找到");
        }
    }
}
